home *** CD-ROM | disk | FTP | other *** search
- global black, white
-
- on EvilTopo srcimg, someLevel, someInverse
- if someLevel < 1 then
- someLevel = 127
- end if
- img1 = srcimg.duplicate()
- img1.fill(img1.rect, rgb(someLevel, someLevel, someLevel))
- if someInverse then
- img1.copyPixels(srcimg, img1.rect, img1.rect, [#ink: 39])
- else
- img1.copyPixels(srcimg, img1.rect, img1.rect, [#ink: 37])
- end if
- return img1
- end
-
- on contrast srcimg, someLevel
- someLevel = someLevel / 2.54999999999999982
- tRect = srcimg.rect
- img1 = srcimg.duplicate()
- img2 = srcimg.duplicate()
- img3 = srcimg.duplicate()
- img1.fill(tRect, rgb(128, 128, 128))
- img2.fill(tRect, rgb(127, 127, 127))
- img2.copyPixels(srcimg, tRect, tRect, [#ink: 39])
- img2.copyPixels(img1, tRect, tRect, [#ink: 33])
- img2.copyPixels(img2, tRect, tRect, [#ink: 4])
- img1.fill(tRect, rgb(128, 128, 128))
- img1.copyPixels(srcimg, tRect, tRect, [#ink: 37])
- img3.fill(tRect, rgb(128, 128, 128))
- img1.copyPixels(img3, tRect, tRect, [#ink: 35])
- useLevel = someLevel
- if (someLevel mod 100) > 0 then
- img3.fill(tRect, rgb(0, 0, 0))
- img3.copyPixels(img1, tRect, tRect, [#blend: useLevel])
- img1 = img3.duplicate()
- img3.fill(tRect, rgb(0, 0, 0))
- img3.copyPixels(img2, tRect, tRect, [#blend: useLevel])
- img2 = img3.duplicate()
- end if
- img3 = srcimg.duplicate()
- img3.copyPixels(img2, tRect, tRect, [#ink: 35])
- img3.copyPixels(img1, tRect, tRect, [#ink: 33])
- return img3
- end
-
- on channel srcimg, somecolor, someInverse
- overimg = srcimg.duplicate()
- case somecolor of
- "red", "green", "blue":
- thisInk = 1
- thisColor = rgb(0, 0, 0)
- otherwise:
- thisInk = 5
- thisColor = rgb(255, 255, 255)
- end case
- hexColor = NameToHex(somecolor)
- if someInverse then
- if thisInk = 1 then
- thisInk = 5
- else
- thisInk = 1
- end if
- end if
- overimg.fill(overimg.rect, hexColor)
- overimg.copyPixels(srcimg, overimg.rect, overimg.rect, [#ink: thisInk, #color: thisColor])
- return overimg
- end
-
- on colorSaturate srcimg, somecolor
- overimg = srcimg.duplicate()
- case somecolor of
- "red", "green", "blue":
- thisInk = 5
- thisColor = rgb(255, 255, 255)
- otherwise:
- thisInk = 1
- thisColor = rgb(0, 0, 0)
- end case
- hexColor = NameToHex(somecolor)
- overimg.fill(overimg.rect, hexColor)
- overimg.copyPixels(srcimg, overimg.rect, overimg.rect, [#ink: thisInk, #color: thisColor])
- return overimg
- end
-
- on EvilColorFlop srcimg, somecolor, someColor2, somePsycho
- overimg = srcimg.duplicate()
- if somePsycho then
- thisInk = 5
- else
- thisInk = 1
- end if
- hexColor = NameToHex(somecolor)
- thisColor = NameToHex(someColor2)
- overimg.fill(overimg.rect, hexColor)
- overimg.copyPixels(srcimg, overimg.rect, overimg.rect, [#ink: thisInk, #color: thisColor])
- return overimg
- end
-
- on NameToHex somecolor
- case somecolor of
- "red":
- hexColor = rgb(255, 0, 0)
- "green":
- hexColor = rgb(0, 255, 0)
- "blue":
- hexColor = rgb(0, 0, 255)
- "cyan":
- hexColor = rgb(0, 255, 255)
- "magenta":
- hexColor = rgb(255, 0, 255)
- "yellow":
- hexColor = rgb(255, 255, 0)
- otherwise:
- hexColor = rgb(0, 0, 0)
- end case
- return hexColor
- end
-
- on duotone srcimg, somecolor, someColor2, someFlop
- Img = EvilColorFlop(srcimg, somecolor, someColor2, someFlop)
- return Img
- end
-
- on psycho srcimg, somecolor, someColor2, someFlop, someInverse
- Img = EvilColorFlop(srcimg, somecolor, someColor2, someFlop)
- if someFlop then
- Img.copyPixels(srcimg, srcimg.rect, srcimg.rect, [#ink: 37])
- else
- Img.copyPixels(srcimg, srcimg.rect, srcimg.rect, [#ink: 39])
- end if
- if someInverse then
- Img.copyPixels(Img, srcimg.rect, srcimg.rect, [#ink: 4])
- end if
- return Img
- end
-
- on invert srcimg
- Img = srcimg.duplicate()
- Img.copyPixels(Img, srcimg.rect, srcimg.rect, [#ink: 4])
- return Img
- end
-
- on saturation srcimg, lvl
- if srcimg.ilk = #image then
- if lvl > 127 then
- nuimg = srcimg.duplicate()
- nuimg.copyPixels(nuimg, nuimg.rect, nuimg.rect, [#ink: 33])
- mm = srcimg.duplicate()
- mm.copyPixels(nuimg, nuimg.rect, nuimg.rect, [#blendLevel: lvl - 127])
- else
- nuimg = srcimg.duplicate()
- mm = srcimg.duplicate()
- mm.copyPixels(desaturate(nuimg, 255), nuimg.rect, nuimg.rect, [#blendLevel: 255 - (lvl * 2)])
- end if
- return mm
- else
- return 0
- end if
- end
-
- on desaturate srcimg, percblend
- if srcimg.ilk = #image then
- bl = 255 - percblend
- new_image = image(srcimg.width, srcimg.height, 8, #grayscale)
- new_image.copyPixels(srcimg, srcimg.rect, srcimg.rect)
- mm = image(srcimg.width, srcimg.height, 32)
- mm.copyPixels(srcimg, srcimg.rect, srcimg.rect)
- mm.copyPixels(new_image, srcimg.rect, srcimg.rect, [#blendLevel: percblend])
- return mm
- else
- return 0
- end if
- end
-
- on sketch Img, treshold
- w = Img.width
- h = Img.height
- R = rect(0, 0, w, h)
- iimg = image(w, h, 32)
- iimg.copyPixels(Img, R, R)
- if Img.useAlpha = 1 then
- nu = Img.duplicate()
- imgg = Img.createMatte(treshold)
- nuu = Img.duplicate()
- nuu.useAlpha = 0
- bw = image(w, h, 8, #grayscale)
- bw.copyPixels(black, R, R, [#maskImage: imgg])
- white = bw
- else
- nu = image(w, h, 8, #grayscale)
- black = image(w, h, 32)
- white = image(w, h, 32)
- black.fill(0, 0, w, h, rgb(0, 0, 0))
- white.fill(0, 0, w, h, rgb(255, 255, 255))
- nu.copyPixels(iimg, R, R)
- iimg.setAlpha(nu)
- iimg.useAlpha = 1
- img2 = iimg.createMatte(treshold)
- white.copyPixels(black, R, R, [#maskImage: img2])
- end if
- return white
- end
-
- on fastsketch Img, treshold
- w = Img.width
- h = Img.height
- R = rect(0, 0, w, h)
- iimg = image(w, h, 32)
- iimg.copyPixels(Img, R, R)
- nu = image(w, h, 8, #grayscale)
- blk = black.duplicate()
- whi = image(w, h, 32)
- nu.copyPixels(iimg, R, R)
- iimg.setAlpha(nu)
- iimg.useAlpha = 1
- img2 = iimg.createMatte(treshold)
- whi.copyPixels(blk, R, R, [#maskImage: img2])
- return whi
- end
-
- on makealpha Img
- w = Img.width
- h = Img.height
- R = rect(0, 0, w, h)
- iimg = image(w, h, 32)
- iimg.copyPixels(Img, R, R)
- nu = image(w, h, 8, #grayscale)
- nu.copyPixels(iimg, R, R)
- iimg.setAlpha(nu)
- iimg.useAlpha = 1
- return iimg
- end
-
- on createalpha Img
- w = Img.width
- h = Img.height
- R = rect(0, 0, w, h)
- nu = image(w, h, 8, #grayscale)
- nu.copyPixels(Img, R, R)
- return nu
- end
-
- on addAlpha imgg, alp
- w = imgg.width
- h = imgg.height
- R = rect(0, 0, w, h)
- Img = image(w, h, 32)
- Img.copyPixels(imgg, R, R)
- Img.setAlpha(alp)
- Img.useAlpha = 1
- return Img
- end
-
- on lumakey imgg, perc
- w = imgg.width
- h = imgg.height
- d = imgg.depth
- R = rect(0, 0, w, h)
- if imgg.useAlpha = 1 then
- nu = image(w, h, d)
- nuu = imgg.duplicate()
- bw = createMatte(nuu, perc)
- bww = image(w, h, 8, #grayscale)
- bww.copyPixels(black, R, R, [#maskImage: bw])
- nuu.useAlpha = 0
- nu.copyPixels(nuu, R, R)
- nu.setAlpha(bww)
- nu.useAlpha = 1
- else
- msk = fastsketch(imgg, perc)
- imggg = image(w, h, 8, #grayscale)
- imggg.copyPixels(msk, R, R)
- nu = addAlpha(imgg, imggg)
- end if
- return nu
- end
-
- on lightness srcimg, someLevel
- someLevel = (someLevel - 127) / 1.27000000000000002
- Img = srcimg.duplicate()
- over = Img.duplicate()
- if someLevel < 0 then
- over.fill(over.rect, rgb(0, 0, 0))
- else
- over.fill(over.rect, rgb(255, 255, 255))
- end if
- someLevel = abs(someLevel)
- Img.copyPixels(over, srcimg.rect, srcimg.rect, [#blend: someLevel])
- return Img
- end
-